<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Payment extends Model
{
    protected $fillable = [
        'user_id',
        'payment_method',
        'amount',
        'action',
        'status',
        'account',
        'acc_password',
    ];

    const TOP_UP = 'top_up';

    const WITHDRAW = 'withdraw';

    public static $ACTION_MAP = [
        self::TOP_UP => '充值',
        self::WITHDRAW => '提現',
    ];

    const PENDING = 'pending';

    const SUCCESS = 'success';

    const FAIL = 'fail';

    public static $STATUS_MAP = [
        'pending' => '待審核',
        'success' => '成功',
        'fail' => '失敗',
    ];

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }

    public static function getPayMethod()
    {
        $data = PayMethod::where('is_show', true)->pluck('name', 'spell')->toArray();

        return $data;
    }
}
